﻿namespace wwm.LeetCodeHelper;

/// <summary>
/// ConsoleHelper
/// </summary>
public static class ConsoleHelper
{
    public static void Success(object str)
    {
        var preForegroundColor = Console.ForegroundColor;
        Console.ForegroundColor = ConsoleColor.Green;
        Console.WriteLine(str);
        Console.ForegroundColor = preForegroundColor;
    }

    public static void Warn(object str)
    {
        var preForegroundColor = Console.ForegroundColor;
        Console.ForegroundColor = ConsoleColor.DarkYellow;
        Console.WriteLine(str);
        Console.ForegroundColor = preForegroundColor;
    }


    public static void Error(object str)
    {
        var preForegroundColor = Console.ForegroundColor;
        Console.ForegroundColor = ConsoleColor.Red;
        Console.WriteLine(str);
        Console.ForegroundColor = preForegroundColor;
    }
    /// <summary>
    /// 输出带有颜色
    /// </summary>
    /// <param name="str"></param>
    /// <param name="color"></param>
    public static void Write(object str, ConsoleColor color)
    {
        var preForegroundColor = Console.ForegroundColor;
        Console.ForegroundColor = color;
        Console.Write(str);
        Console.ForegroundColor = preForegroundColor;
    }
}
